%Copyright (C) 2014 Andreas Orthey
%
%This program is free software: you can redistribute it and/or modify
%it under the terms of the GNU General Public License as published by
%the Free Software Foundation, either version 3 of the License, or
%(at your option) any later version.
%
%This program is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with this program.  If not, see <http://www.gnu.org/licenses/>.

\documentclass[11pt,a4paper]{article}
\usepackage[landscape,textwidth=210mm,textheight=297.02mm]{geometry}
\usepackage{tikz}
\usepackage{ifthen}

\renewcommand{\familydefault}{\sfdefault}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CHANGE NAME INFO AND ADDRESS HERE:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\name}{Sanared Yehtro}
\newcommand{\infofront}{PhD Student\\ Machine Learning, Motion Planning 
\\and Humanoid Robotics}
\newcommand{\infoback}{Doctorant\\ Apprentissage Automatique,
Planification du Movement et Robotique Humanoide}
\newcommand{\mail}{yehtro@my-mail.fr}
\newcommand{\url}{github.com}
\newcommand{\phone}{+0033}
\newcommand{\address}{LAAS-CNRS, Toulouse\\ \url \\ \mail \\ \phone}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CHANGE IMAGES HERE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\imglaas}{\includegraphics[width=30mm]{images/logo_laas.pdf}}
\newcommand{\imgcnrs}{\includegraphics[width=14mm]{images/logo_cnrs.pdf}}
\newcommand{\imgcarnot}{\includegraphics[width=25mm]{images/logo_carnot.png}}
\newcommand{\lmr}{\fontfamily{lmr}\selectfont}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CHANGE SIZE OF TEXT AND INFO HERE:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\namesize}{0.7cm}
\newcommand{\addresssize}{0.36cm}
\newcommand{\infosize}{0.4cm}
\newcommand{\scardwidth}{90mm}
\newcommand{\scardheight}{56mm}

%% 4*verticaldist + 3*scardheight = 200mm
\newcommand{\verticaldist}{3mm}
\setlength{\topmargin}{\verticaldist}
\setlength{\marginparwidth}{0mm}
\setlength{\oddsidemargin}{9mm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO NOT CHANGE ANYTHING HERE; OR YOU SCREW IT UP BIG TIME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%remove top space (use topmargin to adjust levels)
\setlength{\voffset}{-1in}
\setlength{\headheight}{0mm}
\setlength{\headsep}{0mm}
\setlength{\footskip}{0mm}
\setlength{\hoffset}{-1in}

\setlength{\marginparpush}{0pt}
\setlength{\paperwidth}{297.02mm}
\setlength{\paperheight}{210mm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SINGLE VISIT CARD DESIGN
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\singlecardback}{
   \singlecard{2}
}
\newcommand{\singlecardfront}{
   \singlecard{1}
}
\newcommand{\singlecard}[1]{
\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0}]
  %card background
  \draw[color=white, fill=white] (0,0) rectangle (\scardwidth,\scardheight);
  %NAME
  \node at (3,4.5) {
    {\fontsize{\namesize}{1em}\lmr\name}
  };
  %LOGO (TOP RIGHT)
  \node at (7.4,4.5) {
        \imglaas
  };
  %INFORMATION
  \node at (4.5,3.0) {
  \begin{minipage}{7cm}
    \fontsize{\infosize}{1em}\lmr
  \ifthenelse{\equal{#1}{1}}
    {\infofront}{\infoback}
  \end{minipage}
  };
  %LOGO2 (BOTTOM LEFT)
  \node at (1.0,1.1) {
    \imgcnrs
  };
  %LOGO3 (BOTTOM RIGHT)
  \node at (7.4,1.1) {
    \imgcarnot
  };
  %ADDRESS BOTTOM
  \node at (4.0,1.1) {
  \begin{minipage}{4cm}
    \fontsize{\addresssize}{1em}\lmr
    \address
  \end{minipage}
  };
  %LINE SEPARATING ADDRESS AND INFO
  \draw (0.3,2) -- (8.5,2);
\end{tikzpicture}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DRAW CUT LINES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{eso-pic}
\usepackage{calc}

\def\cutlinelength{10mm}
\def\cutlinelengthvert{10mm}
\newlength{\leftrule}
\newlength{\rightrule}
\setlength{\leftrule}{2\leftmargin-\marginparsep}
\setlength{\rightrule}{2\leftmargin+\textwidth+\marginparsep}
\AddToShipoutPicture{%
  \AtPageLowerLeft{%
    \def\lx{67}
    \put(\lx,505){\rule{\cutlinelength}{1pt}}
    \put(\lx,346){\rule{\cutlinelength}{1pt}}
    \put(\lx,322){\rule{\cutlinelength}{1pt}}
    \put(\lx,163){\rule{\cutlinelength}{1pt}}
    \put(\lx,139){\rule{\cutlinelength}{1pt}}
    \put(\lx,-20){\rule{\cutlinelength}{1pt}}

    \def\rx{891}
    \put(\rx,505){\rule{\cutlinelength}{1pt}}
    \put(\rx,346){\rule{\cutlinelength}{1pt}}
    \put(\rx,322){\rule{\cutlinelength}{1pt}}
    \put(\rx,163){\rule{\cutlinelength}{1pt}}
    \put(\rx,139){\rule{\cutlinelength}{1pt}}
    \put(\rx,-20){\rule{\cutlinelength}{1pt}}

    \def\uy{508}
    \put(98, \uy){\rule{1pt}{\cutlinelengthvert}}
    \put(354,\uy){\rule{1pt}{\cutlinelengthvert}}
    \put(364,\uy){\rule{1pt}{\cutlinelengthvert}}
    \put(620,\uy){\rule{1pt}{\cutlinelengthvert}}
    \put(630,\uy){\rule{1pt}{\cutlinelengthvert}}
    \put(886,\uy){\rule{1pt}{\cutlinelengthvert}}

    \def\ly{-50}
    \put(98, \ly){\rule{1pt}{\cutlinelengthvert}}
    \put(354,\ly){\rule{1pt}{\cutlinelengthvert}}
    \put(364,\ly){\rule{1pt}{\cutlinelengthvert}}
    \put(620,\ly){\rule{1pt}{\cutlinelengthvert}}
    \put(630,\ly){\rule{1pt}{\cutlinelengthvert}}
    \put(886,\ly){\rule{1pt}{\cutlinelengthvert}}
  }
}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PRINT 9 CARDS PER PAGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent
\\[-1pt]
\singlecardfront
\singlecardfront
\singlecardfront
\\[\verticaldist]
\singlecardfront
\singlecardfront
\singlecardfront
\\[\verticaldist]          
\singlecardfront
\singlecardfront
\singlecardfront
\\[-1pt]

\newpage
\noindent
\\[-1pt]
\singlecardback
\singlecardback
\singlecardback
\\[\verticaldist]
\singlecardback
\singlecardback
\singlecardback
\\[\verticaldist]
\singlecardback
\singlecardback
\singlecardback
\\[-1pt]
\end{document}
